﻿using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using Microsoft.SharePoint;

using SO.SharePoint.Utilities.Logging;

namespace SO.SharePoint.WebParts.NLBInfoWebPart
{
    public partial class NLBInfoWebPartUserControl : UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                adminPanel.Visible = false;
                userPanel.Visible = true;

                SPWeb web = SPContext.Current.Web;
                if (web.DoesUserHavePermissions(SPBasePermissions.ManageWeb))
                {
                    adminPanel.Visible = true;
                    userPanel.Visible = false;

                    lblPhysicalServerName.Text = Environment.MachineName;
                    lblWebUrl.Text = Request.Url.AbsoluteUri;
                    lblDatabaseName.Text = web.Site.ContentDatabase.Name;
                }
            }
            catch (Exception ex)
            {
                Logging.WriteException(ex);
            }
        }
    }
}
